<template>
	<view class="content">
		<image class="logo" src="/static/logo.png"></image>
		<view class="text-area">
			<text class="title">{{title}}</text>
		</view>
		<view class="color-box" :style="boxStyle" @click="changeBox"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello',
				// 小方块的当前状态
				boxState: 0,
				// 定义不同的方块状态
				boxStates: [
					{ size: 100, color: '#007AFF' },    // 状态0：蓝色，100rpx
					{ size: 150, color: '#FF3B30' },    // 状态1：红色，150rpx
					{ size: 80, color: '#4CD964' },     // 状态2：绿色，80rpx
					{ size: 120, color: '#FFCC00' }     // 状态3：黄色，120rpx
				]
			}
		},
		computed: {
			boxStyle() {
				const state = this.boxStates[this.boxState];
				return {
					width: state.size + 'rpx',
					height: state.size + 'rpx',
					backgroundColor: state.color
				};
			}
		},
		methods: {
			// 点击改变方块状态
			changeBox() {
				this.boxState = (this.boxState + 1) % this.boxStates.length;
				
				console.log('方块状态改变为:', this.boxStates[this.boxState]);
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
	
	/* 小方块的基础样式 */
	.color-box {
		margin-top: 50rpx;
		border-radius: 10rpx;
		transition: all 0.3s ease; 
	}
</style>